<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css" />
</head>
<style>
    .layui-word-aux-error{
        color: red;
    }
</style>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">预测结果标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="forecast_Title" lay-verify="required" autocomplete="off" placeholder="年份-月份预测部门预测结果" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">目标预测时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="forecast_Month"
                                   lay-verify="required" autocomplete="off" placeholder="yyyy-MM" class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">制定预测部门</label>
                        <div class="layui-input-block">
                            <input type="text" name="dept_Name"
                                   lay-verify="required" autocomplete="off" placeholder="请输入部门" class="layui-input">
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">预测人员</label>
                        <div class="layui-input-block">
                            <input type="text" name="emp_Name"
                                   lay-verify="required" autocomplete="off"
                                   placeholder="请输入您的名字" class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">预测结果</label>
                        <div class="layui-input-block">
                            <input type="text" name="forecast_Result"
                                   lay-verify="required" autocomplete="off"
                                   placeholder="请输入预测结果" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>


<script>
    layui.use(['form','jquery','upload','dtree'],function(){
        let form = layui.form;
        let $ = layui.jquery;
        let upload = layui.upload;

        form.on('submit(user-save)', function(data){
            console.log(data.field);
            $.ajax({
                url:'http://localhost:8181/Manager_war/forecastServlet/add',
                data:data.field,
                dataType:'json',
                // contentType:'application/json',form text  请求的格式 给后端是以json格式进行传输
                type:'post',
                success:function(result){
                    if(result.code==0){
                        layer.msg(result.msg,{icon:1,time:1000},function(){
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            window.parent.location.reload()
                        });
                    }else{
                        layer.msg(result.msg,{icon:2,time:1000});
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>
